#include <QtGui/QApplication>
#include "mainwindow.h"
#include <iostream>
#include "histogram.h"
#include "histogramGray.h"
#include "histogramRGB.h"

using namespace std;
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QString inputfilename("Images/sunrise.jpg");
    QImage inputImage;
    inputImage.load(inputfilename);
    if(inputImage.allGray())
        cout << "This is an all gray image" << endl;
    QRgb myPixel=inputImage.pixel(0,0);
    cout << "Blue value= "<< qBlue(myPixel) << endl;
    cout << "Red value= "<< qRed(myPixel) << endl;
    cout << "Green value= "<< qGreen(myPixel) << endl;
    cout << "Gray value= "<< qGray(myPixel) << endl;
    cout << "Alpha value= "<< qAlpha(myPixel) << endl;
    //inputImage.save("tmp.pgm","PGMRAW");
    Histogram* myhisto=new HistogramGray(&inputImage);
    Histogram* myhistoRGB=new HistogramRGB(&inputImage);
    myhisto->calcHistogram();
    myhistoRGB->calcHistogram();
    myhisto->getHistImage()->save("histogram.ppm","PPMRAW");
    myhisto->getHistImage()->save("histogram.pgm","PGMRAW");
    myhistoRGB->getHistImage()->save("histogramRGB.ppm","PPMRAW");
    myhistoRGB->getHistImage()->save("histogramRGB.pgm","PGMRAW");
    delete myhisto;
    delete myhistoRGB;

    return 0;
}
